let wakeLock = null;
function setWakeLock() {
  if (wakeLock) {
    return;
  }
  navigator.wakeLock
    .request("screen")
    .then((lock) => {
      wakeLock = lock;
      wakeLock.addEventListener("release", () => {
        wakeLock = null;
        console.log("Wake Lock released");
      });
    })
    .catch((err) => {
      console.error(`<span class="red">唤醒锁定失败：${err.message}</span>`);
    });
}

if (navigator.wakeLock) {
  //...
} else {
  console.error("浏览器不支持唤醒锁定");
}

if ("BarcodeDetector" in window) {
  const barcode = new BarcodeDetector({
    formats: ["qr_code"],
  });
}
